Fix certificate count error handling in TLS accept - #629
Merged
Conversation
nc_server_tls_get_num_certs() was declared to return uint32_t but returned -1 when resolving a truststore reference failed. The error became UINT32_MAX, which then passed the "neither CA nor end-entity certificates configured" check in nc_accept_tls_session() (a check that could never fire anyway, comparing an unsigned value with <= 0). With a referenced endpoint the two counts were added, so the wrapped value could even come out as a small number. Return the count through an output parameter and the error through the return value instead.
michalvasko
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nc_server_tls_get_num_certs()was declared to returnuint32_tbut returned -1 when a truststore reference could not be resolved. The error became UINT32_MAX and passed the "neither CA nor end-entity certificates configured" check, which could not fire anyway (an unsigned value compared with<= 0). With a referenced endpoint the two counts were added, so the wrapped value could even come out small.Return the count through an output parameter and the error through the return value.